/* 年挽红枫，溪傍芦荻。*/

#define DEBUG true

#if DEBUG
#include <cassert>
#include <iostream>
#include <cmath>
#include <ctime>

bool Mbe;
void _dihan();
#endif

#include <cstdio>
#include <cctype>
#include <algorithm>
#include <set>
#include <vector>

typedef __int128_t i28;
typedef __int64_t i64;
using uit = __uint32_t;
using ull = __uint64_t;

template <typename T>
bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }
template <typename T>
bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }

namespace IO {

#define file(s) freopen(#s".in", "r", stdin), freopen(#s".out", "w", stdout)

constexpr int SIZE = 1 << 21;
char ibuf[SIZE], *p1 = ibuf, *p2 = ibuf, obuf[SIZE], *p3 = obuf;

#define flush() (fwrite(obuf, 1, p3 - obuf, stdout), p3 = obuf)
#define gc() (p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, SIZE, stdin), p1 == p2) ? EOF : *p1++)
#define pc(ch) (p3 == obuf + SIZE && flush(), *p3++ = ch)
class Flush { public: ~Flush() { flush(); } } _;

auto chkChar = [](const char &c) -> bool { return c >= 'a' && c <= 'z'; };
template <typename T>
inline void read(T &x) {
   static char c;
   static bool f;

   x = 0, f = true;
   while (!isdigit(c = gc())) if (c == '-') f = false;

   while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = gc();
   f || (x = ~(x - 1), 0);
}
inline void read(char &c) {
   while (!chkChar(c = gc())) ;
}
inline void read(char *s) {
   static char c;

   while (!chkChar(c = gc())) ;

   while (chkChar(c)) *s++ = c, c = gc();
   *s = '\0';
}

template <typename T>
inline void write(T x) {
   static char stk[50]; static int top;

   x < 0 && (pc('-'), x = ~(x - 1), 1), top = 0;
   do stk[++top] = x % 10 ^ 48; while (x /= 10);

   while (top) pc(stk[top--]);
}
inline void write(char c) { pc(c); }
inline void write(char *s) { while (*s) pc(*s++); }
inline void write(const char *s) {
   for (int i = 0; *(s + i); ++i) pc(*(s + i));
}

template <typename T, typename ...Args>
inline void read(T &first, Args &...args) { read(first), read(args...); }
template <typename T, typename ...Args>
inline void write(T first, Args ...args) { write(first), write(args...); }

}
using namespace IO;

constexpr int N = 1e3 + 5;
constexpr i64 MAXN = 1e18;

int n;
std::vector<i64> a;

class OdlDriver {
 private:
   struct Block {
      i64 l, r;
      int v;

      bool operator <(const Block &b) const {
         return r < b.r;
      }
   };
   std::set<Block> _s;
   i64 _sum;

   void _split(i64 pos) {
      auto it = _s.lower_bound({0, pos, 0});

      if (it->r == pos)
         return;

      Block cur = *it;
      _s.erase(it);
      _s.insert({cur.l, pos, cur.v});
      _s.insert({pos + 1, cur.r, cur.v});
   }

 public:
   void clear() {
      _s.clear();
      _sum = 0;

      _s.insert({0, MAXN, 0});
   }

   void cover(i64 l, i64 r) {
      if (l > r) return;

      _split(l - 1), _split(r);

      auto it = _s.lower_bound({0, l, 0});
      while (it->l < r) {
         _sum -= (it->r - it->l + 1) * it->v;

         it = _s.erase(it);
      }

      _s.insert({l, r, 1});
      _sum += r - l + 1;
   }
   i64 query() {
      return _sum;
   }
} odt;

i64 solve() {
   static int m;
   static i64 mn, mx, res;

   m = (int)a.size() - 1, mn = mx = res = 0;
   for (int i = 0; i < m; ++i) {
      res += mx + a[m - i] - std::max(mx, mn + a[i]);
      mn += a[i], mx += a[m - i];
   }

   return res;
}

int main() {
   file(kte);

   read(n);
   while (n--) {
      i64 x; read(x);

      int p = std::upper_bound(a.begin(), a.end(), x) - a.begin();
      if (!p || a[p - 1] ^ x)
         a.insert(a.begin() + p, x);
      else
         a.erase(a.begin() + p - 1);

      write(solve(), '\n');
   }
#if DEBUG
   _dihan();
#endif
   return 0;
}

#if DEBUG
bool Med;
void _dihan() {
   std::cerr << "Memory: " << abs(&Med - &Mbe) / 1048576.0 << " MB\n";
   std::cerr << "Time: " << 1e3 * clock() / CLOCKS_PER_SEC << " ms\n";
}
#endif
